{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-header">
        <div class="layui-btn-group">
            <a href="{:url('userGroup/add')}" class="layui-btn layui-btn-sm icon-btn ajax-iframe" data-width="410px"><i class="layui-icon">&#xe624;</i> 添加角色</a>
        </div>
    </div>
    
    <table id="tableList" lay-filter="tableList"></table>
    <!-- 表格操作列 -->
    <script type="text/html" id="tableTBTrack">
        <a href="{:url('userGroup/edit')}?id={{d.id}}" class="layui-btn layui-btn-sm icon-btn ajax-iframe" data-width="410px"><i class="layui-icon layui-icon-edit"></i>修改</a>
        <a href="{:url('userGroup/del')}?id={{d.id}}" class="layui-btn layui-btn-danger layui-btn-sm ajax-delete" tiptext="确认删除"><i class="layui-icon layui-icon-delete"></i>删除</a>
    </script>
    <!-- 权限列 -->
    <script type="text/html" id="status">
        <input type="checkbox" name="status" lay-skin="switch" lay-filter="*" lay-text="正常|锁定" data-url="{:url('userGroup/edit')}?id={{d.id}}" {{d.status==1?'checked':''}}>
    </script>
    
    
</div>
{/block}
{block name="js"}
<script>
    layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var dropdown = layui.dropdown;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableList',
            url: "{:url('userGroup/index_json')}",
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
            layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip'] //自定义分页布局
                 //,curr: 5 //设定初始在第 5 页
            ,groups: 1 //只显示 1 个连续页码
            ,first: false //不显示首页
            ,last: false //不显示尾页
            ,prev: '<em>上一页</em>'
            ,next: '<em>下一页</em>'
            ,limit:'15'
            ,limits:['15','30','50','100','200','500']
            } ,
            cellMinWidth: 100,
            limit:'15',
            limits:['15','30','50','100','200','500'],
            size:'lg',even:true,
            cols: [[
                {
                    type:'numbers',
                    title:'#', 
                    width: 60
                }, {
                    field: 'name', 
                    align: 'left', sort: true, 
                    title: '角色名称'
                }, {
                    field: 'description', 
                    align: 'center', 
                    sort: true, 
                    title: '描述'
                }, {
                    align: 'center', 
                    sort: true, 
                    title: '状态',
                    templet:'#status',
                    width:100
                }, {
                    align: 'center', 
                    toolbar: '#tableTBTrack', 
                    title: '操作', 
                    minWidth: 190
                }
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

    });

</script>
{/block}